<?php
	try {
		$filename = rand() . ".png";//要生成的图片名字
		 
		$xmlstr =  $GLOBALS[HTTP_RAW_POST_DATA];
		if(empty($xmlstr)) {
			$xmlstr = file_get_contents('php://input');
		}
		 if (empty($xmlstr)) {
			echo "{\"code\":0,\"msg\":\"未传值\"}";
		 }else{
			$jpg = $xmlstr;//得到post过来的二进制原始数据
			$file = fopen("images/".$filename,"w") or die("{\"code\":3,\"msg\":\"权限问题\"}");//打开文件准备写入

			fwrite($file,$jpg);//写入
			fclose($file);//关闭
			
			echo "{\"code\":1,\"path\":\"" . ("images/".$filename) . "\"}";
		 }
	} catch (Exception $e) {
		echo "{\"code\":2,\"msg\":\"取值出错\"}";
	}
?>
